<?
include_once("test.php");

function waitKeyQ() {
	$ended=0;
	while ($ended==0) {
		while (SDL_PollEvent(&$event)) {
			switch($event["type"]) {					
			case SDL_QUIT:
				echo "SDL_Quit received, quitting\n";
				$ended=1;
				break;
			case SDL_KEYDOWN:
				$keysym=$event["key"]["keysym"]["sym"];
				if ($keysym==SDLK_q) {
					echo "Q pressed, quitting\n";
					$ended=1;
				}
				break;
			}
		}
	}

}
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
	dl('php_sdl.dll');
else 
	dl('sdl.so');
class test_i001 extends test{
	function do_test($idx) {
		switch($idx) {
		case 1:
			echo "Starting\n";
			SDL_Init(SDL_INIT_VIDEO);
			$flags=SDL_HWSURFACE;
			$screen=SDL_SetVideoMode(800, 600, 32, $flags);
			$fmt=$screen["format"];
			$red=SDL_MapRGBA($fmt,255,0,0,255);
			$green=SDL_MapRGBA($fmt,0,255,0,255);
			$blue=SDL_MapRGBA($fmt,0,0,255,255);			


			$i=IMG_Load("contrib/prova.png");
			$r=$i["clip_rect"];
			$r1=$r;
			
			//moving to X=>+100 , Y=>+100
			$r["x"]+=100;
			$r["y"]+=100;		

			//clipping src rect.
			$r1["w"]-=60;	
			$r1["h"]-=60;						

			SDL_BlitSurface($i,$r1,$screen,$r);
			SDL_UpdateRect($screen,0,0,800,600);
						
			waitKeyQ();
			$ret=SDL_Quit();
			
			var_dump($ret);
			echo "Quitting\n";
			break;
		}
	}
	function get_test_list() {
		return array(
			1=>"loading png surface and blitting",
		);
	}
}
?>
